﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;

namespace Utils.Data
{
    public class DataTableGastArbeiter
    {
        public DataTableGastArbeiter()
        {
            //
            // TODO: Add constructor logic here
            //
        } //eof constructor 


        public static string TableToString(ref DataTable dt)
        {
            //string strData = dt.TableName + "\r\n";
            string strData = String.Empty;
            string sep = string.Empty;
            if (dt.Rows.Count > 0)
            {
                //foreach (DataColumn c in dt.Columns)
                //{
                //    if (c.DataType != typeof(System.Guid) &&
                //    c.DataType != typeof(System.Byte[]))
                //    {
                //        strData += sep + c.ColumnName;
                //        sep = "\t";
                //    }
                //}

                //strData += "\r\n";

                foreach (DataRow r in dt.Rows)
                {
                    sep = string.Empty;
                    foreach (DataColumn c in dt.Columns)
                    {
                        if (c.DataType != typeof(System.Guid) &&
                        c.DataType != typeof(System.Byte[]))
                        {
                            if (!Convert.IsDBNull(r[c.ColumnName]))
                                strData += sep +
                                r[c.ColumnName].ToString();
                            else
                                strData += sep + "";
                            sep = "\t";
                        }
                    }
                    strData += "\r\n";
                }
            }
            else
                strData += "\r\n---> Table was empty!";
            return strData;
        } //eof method 
    } //eof class DataTableGastArbeiter

} //eof namespace Utils.Data